using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using Hoshimi._Map_._Zone_;
using Hoshimi._Map_;

namespace Hoshimi
{
	// On trouve le plus proche endroit qui ne soit pas dangereux
	public class NearestSafeLocationTraversal : IZoneTraversal
	{
		// VARIABLES
		protected List<Point> mSafePositionList = new List<Point>();
		protected Point mPoint = Point.Empty;

        // GETTERS & SETTERS
		public List<Point> SafePositionList { get { return this.mSafePositionList; } }

		#region IZoneTraversal Members

		public bool Traversal(ref MapNode node)
		{
			// On ne veut pas qu'il y ait un ennemi ou un mur 
			if (node.mEnnemyZone != 0 || node.mWeigth == 0)
			{
				return true;
			}

			this.mPoint.X = node.X;
			this.mPoint.Y = node.Y;

			if (this.mSafePositionList.Contains(this.mPoint))
			{
				return true;
			}

			this.mSafePositionList.Add(this.mPoint);

			return true;
		}

		#endregion
	}
}
